package com.bookStore.dao;
 
import java.sql.*;
 
public class DBConn {
    public static Connection getConnection() {
    	//mysql数据库端口3306，对应连接的数据库名nitevaluate，并设置数据库连接编码以免mysql默认编码不为utf-8
        String url = "jdbc:mysql://localhost:3306/bookstore?useUnicode=true&characterEncoding=utf-8";   
        String user = "root";                                              //数据库账号
        String pwd = "wangyun";                                           //数据库密码
        Connection conn = null; 
        try {
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            conn = DriverManager.getConnection(url, user, pwd);
        } catch (Exception e) {
            e.getMessage();
        }
        return conn;
    }
}